package org.eenie.cartoonist.api.movie;

import org.eenie.cartoonist.model.MovieEntryEntity;
import org.eenie.cartoonist.provider.OkHttpProvider;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Observable;

/**
 * Created by Eenie on 2016/8/17 16:57.
 * Des：
 */

public class MovieEntryApi {

    public static final String BASE_URL = "https://api.douban.com";
    private MovieEntryService mService;

    public MovieEntryApi() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .client(OkHttpProvider.get())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        mService = retrofit.create(MovieEntryService.class);
    }

    /**
     * example ： 1764796
     *
     * @param id MovieEntry id
     * @return observable
     */
    public Observable<MovieEntryEntity> fetMovieEntryById(String id) {
        return mService.fetEntryDetail(id);
    }


}
